home *** CD-ROM | disk | FTP | other *** search
/ 404 Jogos / CLJG.iso / Diversos / rocketcar2.swf / scripts / frame_14 / PlaceObject2_470_324 / CLIPACTIONRECORD onClipEvent(enterFrame).as next >
Encoding:
Text File  |  2008-09-24  |  1.4 KB  |  96 lines

  1. onClipEvent(enterFrame){
  2.    if(_root.paused)
  3.    {
  4.       return undefined;
  5.    }
  6.    getAngle();
  7.    if(Key.isDown(39))
  8.    {
  9.       xSpeed += xAccel;
  10.    }
  11.    else if(Key.isDown(37))
  12.    {
  13.       xSpeed -= xAccel;
  14.    }
  15.    else
  16.    {
  17.       xSpeed *= 0.9;
  18.    }
  19.    if(Key.isDown(38))
  20.    {
  21.       if(_root.fuel > 0)
  22.       {
  23.          jet = true;
  24.          InAirCauseJet = true;
  25.          _root.fuel--;
  26.       }
  27.    }
  28.    else
  29.    {
  30.       jet = false;
  31.    }
  32.    if(_root.fuel <= 0)
  33.    {
  34.       jet = false;
  35.    }
  36.    if(xSpeed > maxX)
  37.    {
  38.       xSpeed = maxX;
  39.    }
  40.    if(xSpeed < - maxX)
  41.    {
  42.       xSpeed = - maxX;
  43.    }
  44.    _X = _X + xSpeed;
  45.    _Y = _Y + ySpeed;
  46.    if(jet)
  47.    {
  48.       ySpeed -= 1;
  49.    }
  50.    while(_root.bg.hitTest(_X,_Y,true))
  51.    {
  52.       _Y--;
  53.       InAirCauseJet = false;
  54.    }
  55.    while(_root.bg.hitTest(_X,_Y - _height,true))
  56.    {
  57.       _Y++;
  58.       if(ySpeed < 0)
  59.       {
  60.          ySpeed++;
  61.       }
  62.    }
  63.    while(_root.bg.hitTest(_X + _width / 2,_Y - 20,true))
  64.    {
  65.       _X--;
  66.       if(xSpeed > 0)
  67.       {
  68.          xSpeed--;
  69.       }
  70.    }
  71.    while(_root.bg.hitTest(_X - _width / 2,_Y - 20,true))
  72.    {
  73.       _X++;
  74.       if(xSpeed < 0)
  75.       {
  76.          xSpeed++;
  77.       }
  78.    }
  79.    if(_root.bg.hitTest(_X,_Y + 1,true))
  80.    {
  81.       onfloor = true;
  82.       if(!jet)
  83.       {
  84.          ySpeed = 0;
  85.       }
  86.    }
  87.    else
  88.    {
  89.       onfloor = false;
  90.    }
  91.    if(!onfloor)
  92.    {
  93.       ySpeed += gravity;
  94.    }
  95. }
  96.